package official_account

import (
	wechat_official_account_cache_service "code.gitea.io/gitea/services/wechat/cache"
	"code.gitea.io/gitea/services/wechat/errors"
	wechat_service_vo "code.gitea.io/gitea/services/wechat/vo"
)

// GetTempQRStatus 获取微信公众号临时二维码扫码状态
func GetTempQRStatus(
	ticket string,
) (*wechat_service_vo.GetWechatOfficialAccountTempQRStatusVO, error) {

	// 1. 检查参数 ticket
	if len(ticket) == 0 {
		return nil, errors.ErrGetWechatOfficialAccountTempQRStatus{
			Action:  "Get ticket",
			Message: "ticket is empty",
		}
	}

	// 2. 查询缓存，返回 VO 对象
	qrStatusVO, err := wechat_official_account_cache_service.GetWechatOfficialAccountQrStatusByTicket(ticket)
	if err != nil {
		return nil, errors.ErrGetWechatOfficialAccountTempQRStatus{
			Action:  "Query ticket",
			Message: err.Error(),
		}
	}
	return qrStatusVO, nil
}
